import { NgModule } from '@angular/core'
import { Routes, RouterModule } from '@angular/router'

import { UserProfileComponent } from '@shared/components/user-profile/user-profile.component'
import { EditPasswordComponent } from '../../shared/components/edit-password/edit-password.component'
import { DashboardTasksComponent } from './tasks/tasks.component'
import { DashboardTaskDetailComponent } from './tasks/detail/detail.component'
import { StoreDetailTabTerminalComponent } from '../store/detail/tab-terminal/tab-terminal.component'
import { StoreDetailTabQRChannelsComponent } from '../store/detail/tab-qr-channels/tab-qr-channels.component'
import { StoreDetailTabCardChannelsComponent } from '../store/detail/tab-card-channels/tab-card-channels.component'
import { StoreDetailTabSystemComponent } from '../store/detail/tab-system/tab-system.component'
import { StoreDetailTabSettlementComponent } from '../store/detail/tab-settlement/tab-settlement.component'
import { StoreDetailTabQRFunctionComponent } from '../store/detail/tab-qr-function/tab-qr-function.component'
import { StoreDetailTabECChannelsComponent } from '../store/detail/tab-ec-channels/tab-ec-channels.component'
import { StoreDetailTabRiskControlComponent } from '../store/detail/tab-risk-control/tab-risk-control.component'
import { StoreDetailTabUsersComponent } from '../store/detail/tab-users/tab-users.component'
import { TabRulesComponent } from '../post-risk/detail/tab-rules/tab-rules.component'
import { TabRangeComponent } from '../post-risk/detail/tab-range/tab-range.component'
import { TabMccComponent } from '../post-risk/detail/tab-mcc/tab-mcc.component'
import { UserSystemComponent } from '@shared/components/user-profile/tabs/system/user-system.component'
import { UserAuditComponent } from '@shared/components/user-profile/tabs/audit/user-audit.component'
import { ListReuseGuardClass } from '@shared/classes/ListReuseGuardClass'

const routes: Routes = [
  { path: '', redirectTo: 'user/profile', pathMatch: 'full' },
  {
    path: 'tasks/:type',
    redirectTo: 'tasks/:type/list',
  },
  {
    path: 'tasks/:type/list',
    component: DashboardTasksComponent,
    canActivate: [ListReuseGuardClass],
    pathMatch: 'full',
    data: {
      title: '审核',
      titleI18n: 'MENU.AUDIT',
      reuse: true,
    },
  },
  {
    path: 'tasks/:type/:id',
    component: DashboardTaskDetailComponent,
    data: { breadcrumb: 'AUDIT.TITLE.DETAIL' },
    children: [
      { path: '', redirectTo: 'terminals', pathMatch: 'full' },
      { path: 'terminals', component: StoreDetailTabTerminalComponent, data: { titleI18n: 'AUDIT.TITLE.DETAIL' } },
      { path: 'channels/qr', component: StoreDetailTabQRChannelsComponent, data: { titleI18n: 'AUDIT.TITLE.DETAIL' } },
      {
        path: 'channels/card',
        component: StoreDetailTabCardChannelsComponent,
        data: { titleI18n: 'AUDIT.TITLE.DETAIL' },
      },
      { path: 'channels/ec', component: StoreDetailTabECChannelsComponent, data: { titleI18n: 'AUDIT.TITLE.DETAIL' } },
      { path: 'system', component: StoreDetailTabSystemComponent, data: { titleI18n: 'AUDIT.TITLE.DETAIL' } },
      { path: 'settlement', component: StoreDetailTabSettlementComponent, data: { titleI18n: 'AUDIT.TITLE.DETAIL' } },
      { path: 'function/qr', component: StoreDetailTabQRFunctionComponent, data: { titleI18n: 'AUDIT.TITLE.DETAIL' } },
      { path: 'rc', component: StoreDetailTabRiskControlComponent, data: { titleI18n: 'AUDIT.TITLE.DETAIL' } },
      { path: 'users', component: StoreDetailTabUsersComponent, data: { titleI18n: 'AUDIT.TITLE.DETAIL' } },
    ],
  },
  {
    path: 'tasks/:type/:id/postRisk',
    component: DashboardTaskDetailComponent,
    data: { breadcrumb: 'AUDIT.TITLE.DETAIL' },
    children: [
      { path: '', redirectTo: 'rules', pathMatch: 'full' },
      { path: 'rules', component: TabRulesComponent, data: { titleI18n: 'AUDIT.TITLE.DETAIL' } },
      { path: 'range', component: TabRangeComponent, data: { titleI18n: 'AUDIT.TITLE.DETAIL' } },
      { path: 'merchant', component: TabMccComponent, data: { titleI18n: 'AUDIT.TITLE.DETAIL' } },
    ],
  },
  {
    path: 'user/profile',
    component: UserProfileComponent,
    data: { titleI18n: 'DASHBOARD.TITLE.PROFILE' },
    children: [
      {
        path: '',
        redirectTo: 'system',
        pathMatch: 'full',
      },
      {
        path: 'system',
        component: UserSystemComponent,
        data: { titleI18n: 'DASHBOARD.TITLE.PROFILE' },
      },
      {
        path: 'audit',
        component: UserAuditComponent,
        data: { titleI18n: 'DASHBOARD.TITLE.PROFILE' },
      },
    ],
  },
  {
    path: 'user/profile/edit-password',
    component: EditPasswordComponent,
    data: {
      breadcrumb: 'USER.UPDATE_PASSWORD',
      title: 'Update Password',
      titleI18n: 'USER.UPDATE_PASSWORD',
    },
  },
]

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule],
})
export class DashboardRoutingModule {}
